<%--
    Document   : index
    Created on : Jun 1, 2016, 2:06:23 PM
    Author     : niugao
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%
    String GOODID="goodid";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>主页</title>
    <%@ taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"  %>
    <%--<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>--%>
    <link rel="stylesheet" type="text/css" href="../css/main.css">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
    <script src="../js/jquery-1.12.4.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="../js/bootstrap.min.js"></script>
    <style>
        .container input {
            width: 100%;
        }

        .container div {
            margin: 0px 0px;
            outline: none;
        }
    </style>

    <script>


        //当点击删除图片的时候调用
        function deleteRow(img) {
            //出对话框，让用户确认是否删除
            var id = $(img).attr("<%=GOODID%>");
            $("#dialog").attr("<%=GOODID%>", id);
            $("#dialog").modal("show");
        }

        //点了对话框中的确定删除按钮
        function executeDel() {
            var id = $("#dialog").attr("<%=GOODID%>");
            //关掉对话框
            $("#dialog").modal("hide");
            $.getJSON("/login/addtocar",
                    {
                        id:id
                    },
                    function (json,status) {
                        if(json.message==0){
                            alert("请先登录");
                        }
                    }
            );
        }
        //点了对话框中的不删按钮
        function cancelDel() {
            //关掉对话框
            $("#dialog").modal("hide");
        }
    </script>
</head>
<body style="background: url(../img/bg5.jpg) no-repeat fixed center;padding:0px">

<div style="text-align: center;padding: 0px">
    <div class="container" style="padding: 0px">
        <div class="row" style="padding: 0px">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ></div>
            <div class="ol-lg-8 col-md-8 col-sm-8 col-xs-8">
                <jsp:include page="top_bar.jsp" flush="true"/>
            </div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
        </div>
        <div class="row" style="height: 400px">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" >

                </br>
                <jstl:choose>
                    <jstl:when test="${message==1}">
                        <p>当前用户：${name}</p>
                        <p id="llgin"><input type="button" onclick="javascrtpt:window.location.href='/logon/getout'" value="注销登录"></p>
                    </jstl:when>
                    <jstl:otherwise>
                        <p id="llgin"><input type="button" onclick="javascrtpt:window.location.href='/logon/openleft'" value="登录/注册"></p>
                    </jstl:otherwise>
                </jstl:choose>
                </br>
                </br>
                </br>
                <marquee direction="up" height="114" onmouseout="this.start()"
                         onmouseover="this.stop()" scrollAmount="1" scrollDelay="1">
                    <jstl:forEach items="${affiches}" var="std">
                        <img src="../img/sign.gif" />&nbsp;<a href="/affiche/open?affiche_id=${std.id}">${std.title}</a></br>
                    </jstl:forEach>
                    <%--<img src="../img/sign.gif">&nbsp;<a href="#" onClick="window.open('fg-afficheSelect.jsp?id=<%=afficheForm.getId()%>','','width=500,height=400');"><%=afficheForm.getName()%></a><br><br>--%>

                </marquee>

            </div>
            <div class="ol-lg-8 col-md- col-sm-8 col-xs-8" >
                <table cellspacing="20"  border="0" width="67%">
                    <jstl:set value="0" var="sum" />
                    <jstl:forEach items="${goods}" var="std">

                        <%--<jstl:forEach begin="1" end="${fn:length(goods)}" var="item">--%>
                            <jstl:set value="${sum + 1}" var="sum" />
                        <jstl:set value="${sum%3}" var="sum2" />
                        <jstl:set value="1" var="this1" />
                        <jstl:set value="0" var="this0" />

                            <jstl:if test="${sum2==1}">
                            <tr>
                            </jstl:if>
                        <%--</jstl:forEach>--%>

                        <td>
                            <a <%=GOODID%>="${std.id}" style="cursor: pointer" onclick='deleteRow(this)'><img src='${std.image}'/></a>
                            </br>
                                ${std.name}
                            </br>
                                价格：${std.price}元
                        </td>
                        <jstl:if test="${sum2==0}">
                        </tr>
                            </jstl:if>
                    </jstl:forEach>
                </table>
            </div>
        </div>

        <div class="row">
            <div class="ol-lg-4 col-md-4 col-sm-4 col-xs-4"  ></div>

                <jstl:choose>
                    <jstl:when test="${page_pre_index == null}">
                        <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" >上一页</div>
                    </jstl:when>
                    <jstl:otherwise>
                        <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ><a href="/goods/selectHot?page_start_index=${page_pre_index}">上一页</a></div>
                    </jstl:otherwise>
                </jstl:choose>
                <jstl:choose>
                    <jstl:when test="${page_next_index >=goodsLength}">
                        <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" >下一页</div>
                    </jstl:when>
                    <jstl:otherwise>
                        <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ><a href="/goods/selectHot?page_start_index=${page_next_index}">下一页</a></div>
                    </jstl:otherwise>
                </jstl:choose>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
        </div>



        <div class="row">
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2"  ></div>
            <div class="ol-lg-8 col-md-8 col-sm-8 col-xs-8">
                <jsp:include page="bottom.jsp" flush="true" />
            </div>
            <div class="ol-lg-2 col-md-2 col-sm-2 col-xs-2" ></div>
        </div>
    </div>
</div>



<div class="modal fade" id="dialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    订餐
                </h4>
            </div>
            <div class="modal-body">
                是否加入购物车?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="cancelDel()">
                    取消
                </button>
                <button type="button" class="btn btn-primary" onclick="executeDel()">
                    是的
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
</html>
